package com.itheima.fujiati;

import java.util.Random;

public class Demo4 {
    public static void main(String[] args) {
        String name = "令狐冲,风清扬,左冷禅,岳不群,苗人凤";
        String[] s = name.split(",");
        System.out.println("本班人员名单如下:");
        for (int i = 0; i < s.length; i++) {
           if(i%2==1){
               System.out.println(s[i]);
           }else {
               System.out.print(s[i]+" ");
           }
        }
        Random ra = new Random();
        int index = ra.nextInt(s.length);
        System.out.println();
        System.out.println(index);
        System.out.println("本次幸运同学是"+s[index]);
    }
}
